#include "stm32f10x.h"                  // Device header
#include "oled.h"
#include "delay.h"
#include "led.h"
#include "key.h"
extern uint8_t k;

void key_Init()
{
	RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB ,ENABLE );//开启时钟
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//上拉输入，按键按下是低电平，松手是高电平
	GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_11;
	GPIO_InitStructure.GPIO_Speed  = GPIO_Speed_50MHz;//这里配置的是GPIO的输出速度，在输入模式下是没有用的
	GPIO_Init (GPIOB ,&GPIO_InitStructure);//初始化GPIOB
}

void Key_GetNum(uint16_t temperature)
{

	if(GPIO_ReadInputDataBit(GPIOB ,GPIO_Pin_11)==0)
	{
		delay_ms(20);
		while(GPIO_ReadInputDataBit(GPIOB ,GPIO_Pin_11 )==0);
		delay_ms (20);
		
		k++;
		k=k%3;
		OLED_Clear();
		Title_Exchange(k,temperature);

	}
	
}

void Title_Exchange(uint8_t k,uint16_t temperature)
{
	
		if(k==0)
		{
			delay_ms(20);
			Show_Title0(temperature);
		}
		if( k==1 )
		{	
			delay_ms(20);
			Show_Title1();
		}
		if( k==2 )
		{	
			delay_ms(20);
			Show_Title2();
		}		
}
